﻿using System.Collections.Generic;
using System.Linq;

using NHibernate;
using NHibernate.Linq;

using ZQNB.Entity.Dics;

namespace ZQNB.BaseLib.Dics.Impl
{
    public class DicTypeService : IDicTypeService
    {
        private readonly ISession session;

        public DicTypeService(ISession session)
        {
            this.session = session;
        }

        public IQueryable<DicType> QueryTable()
        {
            return session.Query<DicType>();
        }

        public IList<DicType> List(bool? inUse)
        {
            var query = session.Query<DicType>();
            if (inUse.HasValue)
            {
                query = query.Where(x => x.InUse == inUse.Value);
            }

            return query.ToList();
        }
    }
}